package com.venue.hjt.venueclass.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.venue.hjt.venueclass.R;
import com.venue.hjt.venueclass.bean.VenueBean;

import java.util.List;

/**

 */

public class FVenueOrderAdapter extends BaseAdapter {
    private Context mContext;
    private List<VenueBean.ClassHour> list;
    public FVenueOrderAdapter(Context mContext, List<VenueBean.ClassHour> list) {
        this.mContext = mContext;
        this.list = list;
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHander viewHander;
        if (convertView==null){
            viewHander=new ViewHander();
            convertView= View.inflate(mContext, R.layout.fragment_venue_item,null);
            viewHander.tv_venue_order_time=convertView.findViewById(R.id.tv_venue_order_time);
            viewHander.tv_order_jie=convertView.findViewById(R.id.tv_order_jie);
            convertView.setTag(viewHander);
        }else{
            viewHander= (ViewHander) convertView.getTag();
        }

        if (list.get(position).status.equals("0")){
            if (list.get(position).isVenue){
                viewHander.tv_venue_order_time.setBackgroundResource(R.drawable.shape6);
                viewHander.tv_venue_order_time.setTextColor(Color.parseColor("#ffffff"));
            }else{
                viewHander.tv_venue_order_time.setBackgroundResource(R.drawable.shape11);
                viewHander.tv_venue_order_time.setTextColor(Color.parseColor("#b0b0b0"));
            }
            viewHander.tv_venue_order_time.setText(list.get(position).start_time+"～"+list.get(position).end_time);
            viewHander.tv_order_jie.setText("第"+(position+1)+"节");
        }else{
            viewHander.tv_venue_order_time.setText(list.get(position).start_time+"～"+list.get(position).end_time);
            viewHander.tv_venue_order_time.setBackgroundResource(R.drawable.shape10);
            viewHander.tv_venue_order_time.setTextColor(Color.parseColor("#36ec99"));
            viewHander.tv_order_jie.setText("第"+(position+1)+"节");
        }

        return convertView;
    }
    class ViewHander{
        TextView tv_venue_order_time,tv_order_jie;
    }


}
